package com.cipe.cmrs.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.cipe.cmrs.util.Util;


/**
 * @author Incepio
 *
 */

@Entity
@Table(name = "userinfo")
@NamedQueries({
	@NamedQuery(name = "getUserByLoginNameAndPassword", query = " FROM User u where lower(u.loginName) = ? and u.password = ?")
})
public class User extends BaseAuditEntity {

	private static final long serialVersionUID = 2050469065293292560L;
	
	public static final String LOGGED_IN_USER_KEY = "loggedInUserId";
	
	@Column(name="password")
	private String password;
	
	@Transient
	private String newPassword;
	
	@Transient
	private String confirmPassword;
	
	@Column(name="loginname")
	private String loginName;
	
	@Column(name="firstname")
	private String firstName;
	
	@Column(name="middlename")
	private String middleName;
	
	@Column(name="lastname")
	private String lastName;
	
	@Column(name="email")
	private String email;
	
	@Column(name="phone")
	private String phone;
	
	@Column(name="phoneext")
	private String phoneExt;
	
	@Column(name="statuscode")
	private String statusCode;
	
	@Column(name="employeeid")
	private String employeeId;
	
	// Field Office
	
	// Region
	
	// UserType
	

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPhoneExt() {
		return phoneExt;
	}

	public void setPhoneExt(String phoneExt) {
		this.phoneExt = phoneExt;
	}

	public String getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

	public String getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}
	
	public String getFullName(){
		return Util.concate(new String[]{lastName, firstName}, ", ");
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

}
